<?php
/*
	我的下线
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
set_html('title','排行榜');
if($_RQ['op']=='main'){
	$return['params']=array('type'=>0);
	$return['psize']=20;
	$return['list']=array();
	exi($return);
}
if($_RQ['op']=='list'){
	$params=array('uniacid'=>$_SESSION['uniacid']);
	$list=pdo_getall('jy_weishop_store_role',$params,$fields,'','id desc');
	$type=intval($_RQ['type']);
	foreach($list as &$item){
		$workerids=pdo_getall('jy_weishop_store_worker',array('roleid'=>$item['id']),'id','id');
		if($workerids){
			$workerids=array_keys($workerids);
		}else{
			$workerids=-1;
		}
		$params=array('uniacid'=>$_SESSION['uniacid'],'workerid'=>$workerids);
		if($type==1){
			$item['total_price']=pdo_getsum('jy_weishop_store_commission',$params,'total_price');
		}else{
			$item['order_num']=pdo_count('jy_weishop_store_commission',$params);
		}
		$item['member']=cfc('core')->member_show($item['mid']);
	}
	if($type==1){
		paixu($list,'total_price','desc');
	}else{
		paixu($list,'order_num','desc');
	}
	exi($list);
}
?>